import 'package:flutter/material.dart';
import 'package:freemusic/utils/Util.dart';

enum Action { Ok, Cancel }

void showCommonDialog(BuildContext context,
    {String title = "提示",
    String content = "",
    Function onConfirm,
    Function onCancel,
    bool barrierDismissible = true}) {
  Color wordColor = Util.themeColor;
  showDialog(
      barrierDismissible: barrierDismissible,
      context: context,
      builder: (context) => AlertDialog(
            title: Text(title),
            content: Text(content),
            actions: <Widget>[
              FlatButton(
                child: Text(
                  "取消",
                  style: TextStyle(color: wordColor),
                ),
                onPressed: () {
                  if (onCancel == null) {
                    Navigator.pop(context, Action.Cancel);
                  } else {
                    onCancel();
                  }
                },
              ),
              FlatButton(
                child: Text(
                  "确认",
                  style: TextStyle(color: wordColor),
                ),
                onPressed: onConfirm,
              ),
            ],
          ));
}
